// Created from GenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Reflection;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.Generated.AbstractMessage;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using TX = System.String;
using FT = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class PGL_PC6 : AbstractMessage
    {
		/// Constructor
		public PGL_PC6() : base()
        {
			if (MSH != null) {
                MSH.MessageType = new MSG() { MessageCode = "PGL", TriggerEvent = "PC6" };
			}
        }

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PID",2)]
  	    [HL7Field(HL7Version.v23, 2, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v231, 2, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v24, 2, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v25, 3, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v251, 3, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v26, 4, HL7Repeat.False, HL7Required.True,"PID")]
  	    [HL7Field(HL7Version.v27, 4, HL7Repeat.False, HL7Required.True,"PID")]
	    public PID PID {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PATIENT_VISIT",3)]
  	    [HL7Field(HL7Version.v23, 3, HL7Repeat.False, HL7Required.False,"PATIENT_VISIT_PGL_PC6")]
  	    [HL7Field(HL7Version.v231, 3, HL7Repeat.False, HL7Required.False,"PATIENT_VISIT_PGL_PC6")]
  	    [HL7Field(HL7Version.v24, 3, HL7Repeat.False, HL7Required.False,"PATIENT_VISIT_PGL_PC6")]
  	    [HL7Field(HL7Version.v25, 4, HL7Repeat.False, HL7Required.False,"PATIENT_VISIT_PGL_PC6")]
  	    [HL7Field(HL7Version.v251, 4, HL7Repeat.False, HL7Required.False,"PATIENT_VISIT_PGL_PC6")]
  	    [HL7Field(HL7Version.v26, 5, HL7Repeat.False, HL7Required.False,"PATIENT_VISIT_PGL_PC6")]
  	    [HL7Field(HL7Version.v27, 5, HL7Repeat.False, HL7Required.False,"PATIENT_VISIT_PGL_PC6")]
	    public PATIENT_VISIT_PGL_PC6 PATIENT_VISIT {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("GOAL",9)]
  	    [HL7Field(HL7Version.v23, 9, HL7Repeat.True, HL7Required.True,"GOAL_PGL_PC6")]
  	    [HL7Field(HL7Version.v231, 9, HL7Repeat.True, HL7Required.True,"GOAL_PGL_PC6")]
  	    [HL7Field(HL7Version.v24, 9, HL7Repeat.True, HL7Required.True,"GOAL_PGL_PC6")]
  	    [HL7Field(HL7Version.v25, 8, HL7Repeat.True, HL7Required.True,"GOAL_PGL_PC6")]
  	    [HL7Field(HL7Version.v251, 8, HL7Repeat.True, HL7Required.True,"GOAL_PGL_PC6")]
  	    [HL7Field(HL7Version.v26, 9, HL7Repeat.True, HL7Required.True,"GOAL_PGL_PC6")]
  	    [HL7Field(HL7Version.v27, 9, HL7Repeat.True, HL7Required.True,"GOAL_PGL_PC6")]
	    public GOAL_PGL_PC6[] GOAL {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PATHWAY",31)]
  	    [HL7Field(HL7Version.v23, 31, HL7Repeat.False, HL7Required.False,"PATHWAY_PGL_PC6")]
  	    [HL7Field(HL7Version.v231, 31, HL7Repeat.False, HL7Required.False,"PATHWAY_PGL_PC6")]
  	    [HL7Field(HL7Version.v24, 31, HL7Repeat.False, HL7Required.False,"PATHWAY_PGL_PC6")]
	    public PATHWAY_PGL_PC6 PATHWAY {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("OBSERVATION",41)]
  	    [HL7Field(HL7Version.v23, 41, HL7Repeat.False, HL7Required.False,"OBSERVATION_PGL_PC6")]
  	    [HL7Field(HL7Version.v231, 41, HL7Repeat.False, HL7Required.False,"OBSERVATION_PGL_PC6")]
  	    [HL7Field(HL7Version.v24, 41, HL7Repeat.False, HL7Required.False,"OBSERVATION_PGL_PC6")]
	    public OBSERVATION_PGL_PC6 OBSERVATION {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PROBLEM",51)]
  	    [HL7Field(HL7Version.v23, 51, HL7Repeat.False, HL7Required.False,"PROBLEM_PGL_PC6")]
  	    [HL7Field(HL7Version.v231, 51, HL7Repeat.False, HL7Required.False,"PROBLEM_PGL_PC6")]
  	    [HL7Field(HL7Version.v24, 51, HL7Repeat.False, HL7Required.False,"PROBLEM_PGL_PC6")]
	    public PROBLEM_PGL_PC6 PROBLEM {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PROBLEM_OBSERVATION",74)]
  	    [HL7Field(HL7Version.v23, 74, HL7Repeat.False, HL7Required.False,"PROBLEM_OBSERVATION_PGL_PC6")]
  	    [HL7Field(HL7Version.v231, 74, HL7Repeat.False, HL7Required.False,"PROBLEM_OBSERVATION_PGL_PC6")]
  	    [HL7Field(HL7Version.v24, 74, HL7Repeat.False, HL7Required.False,"PROBLEM_OBSERVATION_PGL_PC6")]
	    public PROBLEM_OBSERVATION_PGL_PC6 PROBLEM_OBSERVATION {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("ORDER",86)]
  	    [HL7Field(HL7Version.v23, 86, HL7Repeat.False, HL7Required.False,"ORDER_PGL_PC6")]
  	    [HL7Field(HL7Version.v231, 86, HL7Repeat.False, HL7Required.False,"ORDER_PGL_PC6")]
  	    [HL7Field(HL7Version.v24, 86, HL7Repeat.False, HL7Required.False,"ORDER_PGL_PC6")]
	    public ORDER_PGL_PC6 ORDER {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("SFT",2)]
  	    [HL7Field(HL7Version.v25, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v251, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v26, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v27, 2, HL7Repeat.True, HL7Required.False,"SFT")]
	    public SFT[] SFT {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("UAC",3)]
  	    [HL7Field(HL7Version.v26, 3, HL7Repeat.False, HL7Required.False,"UAC")]
  	    [HL7Field(HL7Version.v27, 3, HL7Repeat.False, HL7Required.False,"UAC")]
	    public UAC UAC {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override Stack<string> ConsumeTextSegments(Stack<string> availableData, HL7ParserOptions options) {

				if (HL7Version.v23 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PATIENT_VISIT = ProcessGroup<PATIENT_VISIT_PGL_PC6>(availableData, options, "PATIENT_VISIT");
		 GOAL = ProcessGroupArray<GOAL_PGL_PC6>(availableData, options, "GOAL");
		 PATHWAY = ProcessGroup<PATHWAY_PGL_PC6>(availableData, options, "PATHWAY");
		 OBSERVATION = ProcessGroup<OBSERVATION_PGL_PC6>(availableData, options, "OBSERVATION");
		 PROBLEM = ProcessGroup<PROBLEM_PGL_PC6>(availableData, options, "PROBLEM");
		 PROBLEM_OBSERVATION = ProcessGroup<PROBLEM_OBSERVATION_PGL_PC6>(availableData, options, "PROBLEM_OBSERVATION");
		 ORDER = ProcessGroup<ORDER_PGL_PC6>(availableData, options, "ORDER");
		}
		if (HL7Version.v231 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PATIENT_VISIT = ProcessGroup<PATIENT_VISIT_PGL_PC6>(availableData, options, "PATIENT_VISIT");
		 GOAL = ProcessGroupArray<GOAL_PGL_PC6>(availableData, options, "GOAL");
		 PATHWAY = ProcessGroup<PATHWAY_PGL_PC6>(availableData, options, "PATHWAY");
		 OBSERVATION = ProcessGroup<OBSERVATION_PGL_PC6>(availableData, options, "OBSERVATION");
		 PROBLEM = ProcessGroup<PROBLEM_PGL_PC6>(availableData, options, "PROBLEM");
		 PROBLEM_OBSERVATION = ProcessGroup<PROBLEM_OBSERVATION_PGL_PC6>(availableData, options, "PROBLEM_OBSERVATION");
		 ORDER = ProcessGroup<ORDER_PGL_PC6>(availableData, options, "ORDER");
		}
		if (HL7Version.v24 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PATIENT_VISIT = ProcessGroup<PATIENT_VISIT_PGL_PC6>(availableData, options, "PATIENT_VISIT");
		 GOAL = ProcessGroupArray<GOAL_PGL_PC6>(availableData, options, "GOAL");
		 PATHWAY = ProcessGroup<PATHWAY_PGL_PC6>(availableData, options, "PATHWAY");
		 OBSERVATION = ProcessGroup<OBSERVATION_PGL_PC6>(availableData, options, "OBSERVATION");
		 PROBLEM = ProcessGroup<PROBLEM_PGL_PC6>(availableData, options, "PROBLEM");
		 PROBLEM_OBSERVATION = ProcessGroup<PROBLEM_OBSERVATION_PGL_PC6>(availableData, options, "PROBLEM_OBSERVATION");
		 ORDER = ProcessGroup<ORDER_PGL_PC6>(availableData, options, "ORDER");
		}
		if (HL7Version.v25 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PATIENT_VISIT = ProcessGroup<PATIENT_VISIT_PGL_PC6>(availableData, options, "PATIENT_VISIT");
		 GOAL = ProcessGroupArray<GOAL_PGL_PC6>(availableData, options, "GOAL");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		}
		if (HL7Version.v251 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PATIENT_VISIT = ProcessGroup<PATIENT_VISIT_PGL_PC6>(availableData, options, "PATIENT_VISIT");
		 GOAL = ProcessGroupArray<GOAL_PGL_PC6>(availableData, options, "GOAL");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		}
		if (HL7Version.v26 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PATIENT_VISIT = ProcessGroup<PATIENT_VISIT_PGL_PC6>(availableData, options, "PATIENT_VISIT");
		 GOAL = ProcessGroupArray<GOAL_PGL_PC6>(availableData, options, "GOAL");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		 UAC = PopSegmentParseAndCheckRequired<UAC>(availableData, options, "UAC");
		}
		if (HL7Version.v27 == options.Version) {
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PATIENT_VISIT = ProcessGroup<PATIENT_VISIT_PGL_PC6>(availableData, options, "PATIENT_VISIT");
		 GOAL = ProcessGroupArray<GOAL_PGL_PC6>(availableData, options, "GOAL");
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		 UAC = PopSegmentParseAndCheckRequired<UAC>(availableData, options, "UAC");
		}
			if (availableData != null && availableData.Count > 0) {
				ConsumeZSegmentsFromText(availableData, options);
			}
            return availableData;
        
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "PGL_PC6";
			}
        }

        static PGL_PC6() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(PGL_PC6));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
			if (MSH != null) {
				segmentData.Add(MSH.GetER7(options));
			}
			if (PID != null) {
				segmentData.Add(PID.GetER7(options));
			}
			if (PATIENT_VISIT != null) {
				segmentData.Add(PATIENT_VISIT.GetER7(options));
			}
			if (GOAL != null && GOAL.Length > 0) {
				for (int i = 0; i < GOAL.Length; i++) {
					segmentData.Add(GOAL[i].GetER7(options));
				}
			}
			if (PATHWAY != null) {
				segmentData.Add(PATHWAY.GetER7(options));
			}
			if (OBSERVATION != null) {
				segmentData.Add(OBSERVATION.GetER7(options));
			}
			if (PROBLEM != null) {
				segmentData.Add(PROBLEM.GetER7(options));
			}
			if (PROBLEM_OBSERVATION != null) {
				segmentData.Add(PROBLEM_OBSERVATION.GetER7(options));
			}
			if (ORDER != null) {
				segmentData.Add(ORDER.GetER7(options));
			}
			if (SFT != null && SFT.Length > 0) {
				for (int i = 0; i < SFT.Length; i++) {
					segmentData.Add(SFT[i].GetER7(options));
				}
			}
			if (UAC != null) {
				segmentData.Add(UAC.GetER7(options));
			}
           segmentData.AddRange(GetZSegmentsER7(options));
		   return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }


    }
}

